<?
/*
 * 网站URL
 * by:一平
*/
class surl
{
	/**
	 * 得得网站的首页
	 */
	static public function home()
	{
		return "http://www.".SITE_DOMAIN."/";	
	}
	/**
	 * 得到本页的URL
	 */
	static public function url()
	{
	    return "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
	}
	/**
	 * 得到各各产品的ROOT
	 */
	static public function get($subSite="")
	{
		//得到本页URL
		if(empty($subSite))
			return self::url();		
		//二级域名URL
		global $scfg;
		if(SUBSITE_DOMAIN || $scfg["substation"]["subSiteDomainEspecially"][$subSite] || $subSite == 'www')
			return "http://{$subSite}.".SITE_DOMAIN."/";
		//目录URL
		return "http://www.".SITE_DOMAIN."/{$subSite}/";
	}
	/**
	 * 功能:得到URL
	 * 參數:$url,$data
	 * 返回:string URL
	 */
	static public function en($url,$data)
	{
		if(is_array($data))
		{
			arsort($data);
			$rs = array();
			foreach($data as $k=>&$v)
				if($v === "0" || $v) 
					$rs[] = "{$k}=".urlencode($v);
			if($rs)
				return $url.(strstr($url,'?')?'&':'?').implode('&',$rs);
		}
		return $url;		
	}
	/**
	 * 功能:URL
	 */
	static public function set($arr=array())
	{
	    $g = $_GET;
	    foreach($arr as $k=>&$v)
	    	$g[$k] = $v;
	    return self::en($_SERVER["PHP_SELF"],$g);
	}
}
?>